package serialport;



import java.io.File;
import java.io.IOException;

import android_serialport_api.SerialPort;

/**
 * Created by admin on 2017/11/21.
 */
public class SerialPortManager {

    //"/dev/ttyS1", 9600
    public static SerialPort getSerialPort(String path, int baudRate) {
         SerialPort mSerialPort = null;
//        if (mSerialPort == null) {
            try {
                mSerialPort = new SerialPort(new File(path), baudRate,0);
            } catch (IOException e) {
                e.printStackTrace();
            }
//        }
        return mSerialPort;
    }

    public  static void closeSerialPort( SerialPort mSerialPort) {
        if (mSerialPort != null) {
            mSerialPort.close();
            mSerialPort = null;
        }
    }
}
